package com.ruoyi.project.orderSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.orderSystem.domain.VDeclareImage;
import com.ruoyi.project.orderSystem.service.IVDeclareImageService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 申报图片Controller
 * 
 * @author wangshuo
 * @date 2021-02-03
 */
@RestController
@RequestMapping("/orderSystem/declareimage")
public class VDeclareImageController extends BaseController
{
    @Autowired
    private IVDeclareImageService vDeclareImageService;

    /**
     * 查询申报图片列表
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:declareimage:list')")
    @GetMapping("/list")
    public TableDataInfo list(VDeclareImage vDeclareImage)
    {
        startPage();
        List<VDeclareImage> list = vDeclareImageService.selectVDeclareImageList(vDeclareImage);
        return getDataTable(list);
    }

    /**
     * 导出申报图片列表
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:declareimage:export')")
    @Log(title = "申报图片", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(VDeclareImage vDeclareImage)
    {
        List<VDeclareImage> list = vDeclareImageService.selectVDeclareImageList(vDeclareImage);
        ExcelUtil<VDeclareImage> util = new ExcelUtil<VDeclareImage>(VDeclareImage.class);
        return util.exportExcel(list, "declareimage");
    }

    /**
     * 获取申报图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:declareimage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(vDeclareImageService.selectVDeclareImageById(id));
    }

    /**
     * 新增申报图片
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:declareimage:add')")
    @Log(title = "申报图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VDeclareImage vDeclareImage)
    {
        return toAjax(vDeclareImageService.insertVDeclareImage(vDeclareImage));
    }

    /**
     * 修改申报图片
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:declareimage:edit')")
    @Log(title = "申报图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VDeclareImage vDeclareImage)
    {
        return toAjax(vDeclareImageService.updateVDeclareImage(vDeclareImage));
    }

    /**
     * 删除申报图片
     */
    @PreAuthorize("@ss.hasPermi('orderSystem:declareimage:remove')")
    @Log(title = "申报图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vDeclareImageService.deleteVDeclareImageByIds(ids));
    }
}
